package com.chhlz.core.util;

import java.util.Calendar;
import java.util.Date;
import java.util.Random;

public class CommonTools {
	
	public static String genBillNumber(){
		Calendar c = Calendar.getInstance();
		int h = c.get(Calendar.HOUR_OF_DAY);
		int m = c.get(Calendar.MINUTE);
		int s = c.get(Calendar.SECOND);
		Random r = new Random();
		StringBuilder sb = new StringBuilder();
		sb.append(h).append(m).append(s);
		for (int i = 0; i < 3; i++){
			sb.append(r.nextInt(10));
		}
//		System.out.println("h " + h + ",m " + m + ",s " + s);
		return sb.toString();
	}
	
	public static String genTime(){
		StringBuilder sb = new StringBuilder();
		Calendar c = Calendar.getInstance();
		int y = c.get(Calendar.YEAR);
		int m = c.get(Calendar.MONTH) + 1;
		int d = c.get(Calendar.DAY_OF_MONTH);
		int h = c.get(Calendar.HOUR_OF_DAY);
		int min = c.get(Calendar.MINUTE);
		int s = c.get(Calendar.SECOND);
		sb.append(y).append("-")
			.append(m).append("-")
			.append(d).append(" ")
			.append(h).append(":")
			.append(min).append(":")
			.append(s);
		return sb.toString();
	}
	
	public static void main(String[] args){
		System.out.println(genBillNumber());
		System.out.println(new Date().getTime());
	}

}
